/*-------------------------------------------------
#
# Project created by chenswe
#
#				2015 - 12 - 2
#
#-------------------------------------------------*/



#ifndef BINARYTREE_H_
#define BINARYTREE_H_ 

#include "Public.h"
#include <cstdlib>
#include <iostream>
using namespace std;

class BinaryTree {
	 
	friend istream& operator>>(istream &input, BinaryTree  &tree);
	friend ostream& operator<<(ostream &output, BinaryTree  &tree);

public:
	BinaryTree (char data = '#', 
		BinaryTree *lchild = NULL, 
		BinaryTree *rchild = NULL);
	Status CreateBiTree();

	void operator=(BinaryTree &tree);
	BinaryTree (BinaryTree &);

	~BinaryTree();
	
	char getData() const;
	BinaryTree *getLChild() const;
	BinaryTree *getRChild() const;

	Status setData(char data);
	Status setLChild(BinaryTree *child);
	Status setRChild(BinaryTree *child);

	Status clear();								//clear this tree
	bool isEmpty();								//Empty or not
	int  getDepth();							//get the depth of this tree;
	int	 getNodeNum();							//get the number of node int this tree;
	int getLeafNum();							//get the number of leafs;
	Status swap();								//swap every node's left subtree and right subtree;
	Status preOrderfind(int &index, const int getNodeNum);				


	//judge the two tree are equal or not;
	bool operator==(BinaryTree  &tree);
	bool similar(BinaryTree  &tree);

	int outputTip();
	Status visit();
	Status Traverse(ways way);

	Status recurPreOrderTraverse();
	Status recurInOrderTraverse();
	Status recurPostOrderTraverse();
	Status levelOrderTraverse();

	Status NonRecurPerVisit();
	Status NonRecurInVisit();
	Status NonRecurPostVisit();

private:
	char m_cData;
	BinaryTree *m_LChild;
	BinaryTree *m_RChild;
};


#endif

